#A very simple webserver..


webdir='.'
port = 8000

import os, sys
from BaseHTTPServer import HTTPServer
from CGIHTTPServer import CGIHTTPRequestHandler

import socket
import fcntl
import struct
ifname='eth0'
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
ip =  socket.inet_ntoa(fcntl.ioctl(
        	s.fileno(),
        	0x8915,  # SIOCGIFADDR
        	struct.pack('256s', ifname[:15])
    	)[20:24])
os.chdir(webdir)
srvaddr = (ip,port)
srvobj = HTTPServer(srvaddr,CGIHTTPRequestHandler)
srvobj.serve_forever() 


